using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Administrator_MasterPage : System.Web.UI.MasterPage
{
    UserBll accBll = new UserBll();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {            
            if (Session["login"] != null)
            {
                if ((Session["login"] as User).Role.CompareTo("Admin")!=0)
                    showMessage("You are not admin", "../News.aspx");
                else
                    lblAdminLogin.Text = "Welcome " + (Session["login"] as User).UserName;
            }
            else
                showMessage("You must login to join News", "../Home.aspx");
            
        }
    }

    public void showMessage(string mess, string url)
    {
        string strBuilder = "<script language='javascript'>alert('" + mess + "'); window.location=('" + url + "');</script>";
        Response.Write(strBuilder);
    }
    protected void lbtnLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Session.Abandon();
        showMessage("Logout is successful!", "../News.aspx");
    }
}
